package cn.rxmind.dlicense.core.validator;

import cn.rxmind.dlicense.core.base.DLicenseContent;
import cn.rxmind.dlicense.core.utils.MachineInfoUtil;
import lombok.Setter;

import java.util.Set;

/**
 * MAC 地址校验
 *
 * @author renxin
 * @email renxinzhiliangzhi@163.com
 * @date 2021/4/15 2:58 下午
 */
public class MacAddressLicenseValidator extends AbstractExitJVMLicenseValidator {

    @Override
    public String description() {
        return "MAC 地址校验";
    }

    @Override
    protected ValidateResult validateResult(DLicenseContent content) {

        Set<String> macAddress = MachineInfoUtil.getMacAddress();
        boolean valid = content.getMacRule().test(macAddress);

        return new ValidateResult().setValid(valid).setLicenseValidator(this.getClass()).setDescription(valid ? "valid" : "Mac 地址不匹配");
    }
}
